package com.example.sample.logic.fsm;

import com.example.sample.SampleApp;
import com.example.sample.logic.fsm.base.FSMEvt;
import com.example.sample.logic.fsm.base.FSMState;

import net.liteheaven.xblib.common.ui.ToastUtil;

public class FSMStateNormal extends FSMState {

    @Override
    protected int getStateValue() {
        return TestFSMConst.STATE_Normal;
    }

    @Override
    protected void onActive() {
        ToastUtil.show(SampleApp.getApp(), "欢迎来到聊天室");
    }

    @Override
    protected void handleEvt(FSMEvt evt) {
        switch (evt.getEvtValue()){
            case TestFSMConst.EvtRestoreToNormal:
                ToastUtil.show(SampleApp.getApp(), "没有被禁言，不需要解禁");
                break;
            case TestFSMConst.EVT_MSG:
                FSMEvtMsg e = (FSMEvtMsg) evt;
                if (e.msg.contains("x")){
                    changeState(TestFSMConst.STATE_NoSay);
                    return;
                }

                ToastUtil.show(SampleApp.getApp(), "发送成功..." + e);
                break;

        }
    }
}
